using System;
using Caramel.Entities;

namespace Caramel.FluentNHibernate.Conventions
{
	public class MutableEntityConvention : global::FluentNHibernate.Conventions.IPropertyConvention
	{
		#region IConvention<IPropertyInspector,IPropertyInstance> Members

		public void Apply(global::FluentNHibernate.Conventions.Instances.IPropertyInstance instance)
		{
			if (typeof(IMutable).IsAssignableFrom(instance.Property.DeclaringType))
			{
				foreach (var property in new[] { "Created", "CreatedBy"/*, "Updated", "UpdatedBy"*/ })
				{
					new NotNullConvention(property).Apply(instance);
				}
			}
		}

		#endregion
	}
}
